package vip.meeet.dpattern.singleton;

public class DCLSingleton {

    /**
     * volatile禁止重排序
     */
    private static volatile DCLSingleton singleton;
    private DCLSingleton() {
    }
    public static DCLSingleton getInstance() {
        if (singleton == null) {
            synchronized (DCLSingleton.class) {
                if (singleton == null) {//双重检查
                    singleton = new DCLSingleton();
                }
            }
        }
        return singleton;
    }
}
